Xbasic

FILTER_STRING_SMATCH Function

Syntax

String_Array[] as C = FILTER_STRING_SMATCH(C string ,C pattern,[C delimiter[,L exclude]])

Arguments

string

A character string separated into "records" by the character string Delimiter.

pattern

A character string to find in each "record" of the Input_List. Can include the '*' and '? ' wildcard characters.

delimiter

A character string that separates the Input_List into multiple "records".

exclude

Logical. Optional. The default value for Exclude_Flag is .F. (FALSE). .T. = The String_Array[] excludes the "records" that contain sub-string. .F. = The String_Array[] contains only the "records" that contain the Find_String.

Description

Filter in/out words that match (using smatch) the pattern, default delimiter is CR-LF.

Discussion

FILTER_STRING_SMATCH() takes an Input_List that is divided into logical "records" by a Delimiter and either extracts or excludes the "records" that contain the Find_String characters anywhere within each "record" in the string. This function is typically used in Xbasic scripts. It is extremely useful for manipulating the CR-LF delimited strings that are returned by many of the Alpha Anywhere methods (such as A5.FORM_ENUM()). NOTE : FILTER_STRING_SMATCH() is not case sensitive.

Example

list = <<%a%
Alpha Software
The Alpha Project
Project Alpha
%a%
? filter_string(list, "alpha", crlf() )
=   Alpha Software
The Alpha Project
Project Alpha
? filter_string_smatch(list, "alpha", crlf() )
= ""
? filter_string_smatch(list, "alpha*", crlf() )
= Alpha Software
? filter_string_smatch(list, "*alpha", crlf() )
= Project Alpha
? filter_string_smatch(list, "*alpha*", crlf() )
= Alpha Software
The Alpha Project
Project Alpha

See Also